package com.qidian.study.service.impl;

import com.qidian.study.dao.AdminDAO;
import com.qidian.study.dao.impl.AdminDAOImpl;
import com.qidian.study.pojo.Admin;
import com.qidian.study.service.AdminService;
import com.qidian.study.util.pojo.VideoResponse;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 */
public class AdminServiceImpl implements AdminService {
    private AdminDAO adminDAO = new AdminDAOImpl();
    public VideoResponse save(Admin admin) {
        // 查重
        Admin a = adminDAO.queryByName(admin.getAdminName());
        if(a!=null){
            return VideoResponse.error(505);// 表示重复
        }
        // 查重通过，就开始保存
        if(adminDAO.save(admin)==1){
            return VideoResponse.ok();
        }
        return VideoResponse.error();
    }
}
